package samples.d1
{
	import flash.utils.setInterval;
	import samples.BaseSample;
	import shapes.shapes2D.Dot;
	import shapes.shapes2D.Line;
	/**
	 * @author Nicolas Barradeau
	 * http://en.nicoptere.net
	 */
	public class Sample4 extends BaseSample
	{
		
		private var line:Line;
		private var d0:Dot;
		private var d1:Dot;
		
		private var iteration:int = 0;
		private var limit:int = 25;
		
		public function Sample4() 
		{
			
			
			d0 = new Dot( 100, sh / 2 );
			d1 = new Dot( sw - 100, sh / 2 );
			line = new Line( d0, d1 );
			line.start = 0;
			line.end = -1;
			
			
			interval = setInterval( render, 30 );
			
		}
		
		private function render():void
		{
			
			if ( iteration > limit )
			{
				iteration = 0;
				graphics.clear();
				return;
			}
			
			iteration++;
			line.start = Math.random();
			line.end = -Math.random();
			
			
			graphics.lineStyle( 0, color );
			d0.draw( graphics );
			d1.draw( graphics );
			
			graphics.lineStyle( Math.random() * 20, color, iteration / limit );
			line.draw( graphics );
			
		}
		
	}

}